package com.jindy.module.salesFinancialStatistics.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.enums.BusinessType;
import com.jindy.module.salesFinancialStatistics.domain.SalesFinancialStatisticsView;
import com.jindy.module.salesFinancialStatistics.service.ISalesFinancialStatisticsViewService;
import com.jindy.common.utils.poi.ExcelUtil;
import com.jindy.common.core.page.TableDataInfo;

/**
 * 销售订单统计Controller
 * 
 * @author jindy
 * @date 2023-06-08
 */
@RestController
@RequestMapping("/module/salesFinancialStatistics")
public class SalesFinancialStatisticsViewController extends BaseController
{
    @Autowired
    private ISalesFinancialStatisticsViewService salesFinancialStatisticsViewService;

    /**
     * 查询销售订单统计列表
     */
    @PreAuthorize("@ss.hasPermi('module:salesFinancialStatistics:list')")
    @GetMapping("/list")
    public TableDataInfo list(SalesFinancialStatisticsView salesFinancialStatisticsView)
    {
        startPage();
        List<SalesFinancialStatisticsView> list = salesFinancialStatisticsViewService.selectSalesFinancialStatisticsViewList(salesFinancialStatisticsView);
        return getDataTable(list);
    }

    /**
     * 导出销售订单统计列表
     */
    @PreAuthorize("@ss.hasPermi('module:salesFinancialStatistics:export')")
    @Log(title = "销售订单统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SalesFinancialStatisticsView salesFinancialStatisticsView)
    {
        List<SalesFinancialStatisticsView> list = salesFinancialStatisticsViewService.selectSalesFinancialStatisticsViewList(salesFinancialStatisticsView);
        ExcelUtil<SalesFinancialStatisticsView> util = new ExcelUtil<SalesFinancialStatisticsView>(SalesFinancialStatisticsView.class);
        util.exportExcel(response, list, "销售订单统计数据");
    }

    /**
     * 获取销售订单统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:salesFinancialStatistics:query')")
    @GetMapping(value = "/{leaseMonth}")
    public AjaxResult getInfo(@PathVariable("leaseMonth") String leaseMonth)
    {
        return AjaxResult.success(salesFinancialStatisticsViewService.selectSalesFinancialStatisticsViewByLeaseMonth(leaseMonth));
    }

    /**
     * 新增销售订单统计
     */
    @PreAuthorize("@ss.hasPermi('module:salesFinancialStatistics:add')")
    @Log(title = "销售订单统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SalesFinancialStatisticsView salesFinancialStatisticsView)
    {
        return toAjax(salesFinancialStatisticsViewService.insertSalesFinancialStatisticsView(salesFinancialStatisticsView));
    }

    /**
     * 修改销售订单统计
     */
    @PreAuthorize("@ss.hasPermi('module:salesFinancialStatistics:edit')")
    @Log(title = "销售订单统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SalesFinancialStatisticsView salesFinancialStatisticsView)
    {
        return toAjax(salesFinancialStatisticsViewService.updateSalesFinancialStatisticsView(salesFinancialStatisticsView));
    }

    /**
     * 删除销售订单统计
     */
    @PreAuthorize("@ss.hasPermi('module:salesFinancialStatistics:remove')")
    @Log(title = "销售订单统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{leaseMonths}")
    public AjaxResult remove(@PathVariable String[] leaseMonths)
    {
        return toAjax(salesFinancialStatisticsViewService.deleteSalesFinancialStatisticsViewByLeaseMonths(leaseMonths));
    }
}
